$(document).ready(function() {	
	$("#frmChangePass").validate({
		errorClass		: 'error',
		errorElement	: 'span',
		onfocusout		: false,
		onkeyup			: false,
		ignore			: "input[type='text']:hidden",
		rules: {		
			ppassword_old: {
				required			: true,
				passwordValid		: true
			},
			ppassword : {	
				required			: true,
				minlength			: 5,
				equalTo				: '#ppassword_confirm'
			},
			ppassword_confirm: {
				required			: true
			}
		},
		messages: {		
			ppassword_old: {
				required			: password_old_required,
				passwordValid		: password_old_invalid
			},
			ppassword : {				
				required			: password_required,
				minlength			: password_minlength,
				equalTo				: password_notmatch
			},
			ppassword_confirm: {
				required			: password_confirm_required
			}
		},
		errorPlacement: function(label, element) {			
			var id = element.attr('id');			
			label.insertAfter($('#' + id));			
		},
		submitHandler: function(form) {	
			var strPasswordOld = $('#ppassword_old').val();
			if(strPasswordOld != undefined) {
				var strChap	= MD5(strPasswordOld);
				$('#ppassword_old').val(strChap);
			}
			form.submit();
		}
	});	
	$.validator.addMethod('passwordValid', function(){
		var strPasswordOld = $('#ppassword_old').val();
		var strChap			= MD5(MD5(strPasswordOld));
		var strUrl 		= HOST_BACKEND + 'valid/isvalidpassword';
		$.ajax({
			cache	: false,
            async	: false,
            type	: 'POST',
			data	: 'password=' + strChap,
			url		: strUrl,
			success	: function(response) {
				result = (response == 1) ? true : false;
			}
		});
		return result;
	});
});